home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: watzka@stat.uni-muenchen.de (Kurt Watzka)
- Newsgroups: comp.lang.c
- Subject: Re: help with strcmp
- Date: 2 Apr 1996 21:00:51 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4js4i3$17i@sparcserver.lrz-muenchen.de>
- References: <4jpiek$lp6@blaze.cs.jhu.edu> <316196CB.1125@diagram.fr> <4jr75p$onk@sparcserver.lrz-muenchen.de> <828453979snz@genesis.demon.co.uk>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- Lawrence Kirby <fred@genesis.demon.co.uk> writes:
-
- >In article <4jr75p$onk@sparcserver.lrz-muenchen.de>
- > watzka@stat.uni-muenchen.de "Kurt Watzka" writes:
-
- >>strcmp() and strncmp() are designed to handle C strings, so they know how
- >>to treat '\0' in a string. Otherwise
- >>
- >> int STRCMP(const char *s1, const char *s2)
- >> {
- >> size_t sz1 = strlen(s1), sz2 = strlen(s2);
- >> return strncpm(s1, s2, sz1 < sz2 ? sz1 : sz2);
- >> }
-
- >Do you have suppressed yearnings for obsolete OSs? ;-)
-
- Yes, esp. in the afternoon when it is too late for coffee and to
- early for tea.
-
- >>would be a common replacement for the then useless strcmp() function.
-
- >Not quite, it would compare "A" and "AB" as equal.
-
- That is exactly my point. If strcmp() would not knowe how to deal
- with a '\0' in a string, comparing strings of different lenght
- would be difficult, no matter how large the buffers that hold the
- two strings are.
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
-